package com.freeland.client2009.dao.ibatis.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.freeland.client2009.dao.ibatis.GameInfoDAO;
import com.freeland.client2009.dao.ibatis.model.GameInfo;
import com.freeland.client2009.dao.ibatis.model.Usgameinfo;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository("gameInfoDao")
public class GameInfoDAOImpl extends SqlMapClientDaoSupport implements GameInfoDAO {

	@Resource(name="sqlMapClient")
	public void setSqlMapClientFactory(SqlMapClient sqlMapClient)
	{
		this.setSqlMapClient(sqlMapClient);
	}
    public GameInfoDAOImpl() {
        super();
    }

    public int updateByPrimaryKey(GameInfo record) {
        int rows = getSqlMapClientTemplate().update("update_GameInfo_ByPrimary", record);
        return rows;
    }

    @SuppressWarnings("unchecked")
	public List<GameInfo> selectByParameter(GameInfo gameInfo) {
    	return getSqlMapClientTemplate().queryForList("select_GameInfo_byParameter", gameInfo);
    }
    @SuppressWarnings("unchecked")
	public List<GameInfo> selectPushedGameListByAreaId(String areaId,String userType) {
    	Map map = new HashMap();
    	map.put("areaId", areaId);
    	map.put("userType", userType);
    	
    	return getSqlMapClientTemplate().queryForList("select_PushedGameInfo_byAreaId", map);
    }
    @SuppressWarnings("unchecked")
    public List<GameInfo> selectPushedGameListByNetBarId(String netBarId) {
    	return getSqlMapClientTemplate().queryForList("select_PushedGameInfo_byNetBarId", netBarId);
    }
    @SuppressWarnings("unchecked")
	public List<GameInfo> selectDeletedGameListByAreaId(String areaId,String userType) {
    	Map map = new HashMap();
    	map.put("areaId", areaId);
    	map.put("userType", userType);
    	
		return getSqlMapClientTemplate().queryForList("select_DeletedGameInfo_byAreaId", map);
		  
	}
    @SuppressWarnings("unchecked")
	public List<GameInfo> selectDeletedGameListByNetBarId(String netBarId) {
		return getSqlMapClientTemplate().queryForList("select_DeletedGameInfo_byNetBarId", netBarId);
		  
	}
    /**
     * 根据gameId来查询
     * @param gameId
     * @return
     */
    public GameInfo selectByPrimaryKey(String gameId){
    	return (GameInfo)getSqlMapClientTemplate().queryForObject("select_GameInfo_byPrimaryKey", gameId);
    }
    
    /**
     * 新增
     * @param info
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
	public void insertGameInfo(String gameId,String gamePy,String gameName,int idcGamever,int localVersion,Date createTime,String gameSize){
    	Map map= new HashMap();
    	map.put("gameId", gameId);
    	map.put("gamePy", gamePy);
    	map.put("gameName", gameName);
    	map.put("idcGamever", idcGamever);
    	map.put("localVersion", localVersion);
    	
    	map.put("createTime",createTime);
    	map.put("releasetTime",createTime);
    	
    	map.put("gameSize",gameSize);
    	
    	getSqlMapClientTemplate().insert("insert_GameInfo", map);
    }
    /**
     * 更新
     * @param gameId
     * @param idcGamever
     * @param localVersion
     * @param updateTime
     * @param gameSize
     */
    @SuppressWarnings("unchecked")
	public void updateGameInfo(String gameId,int idcGamever,int localVersion,Date updateTime,String gameSize){
    	@SuppressWarnings("rawtypes")
		Map map= new HashMap();
    	map.put("gameId", gameId);
    	map.put("idcGamever", idcGamever);
    	map.put("localVersion", localVersion);
    	map.put("releasetTime",updateTime);
    	
    	map.put("gameSize",gameSize);
    	
    	getSqlMapClientTemplate().update("update_GameInfo", map);
    }
    /**
     * 
     * @param gameId
     * @param gamePy
     * @param gameName
     * @param idcGamever:默认为：10
     * @param localVersion：默认为：10
     * @param createTime
     * @param gameSize
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
	public void insertMakeGameInfo(String gameId,String gamePy,String gameName,int idcGamever,int localVersion,Date createTime,String gameSize){
    	Map map= new HashMap();
    	map.put("gameId", gameId);
    	map.put("gamePy", gamePy);
    	map.put("gameName", gameName);
    	map.put("idcGamever", idcGamever);
    	map.put("localVersion", localVersion);
    	
    	map.put("createTime",createTime);
    	map.put("releasetTime",createTime);
    	
    	map.put("gameSize",gameSize);
    	
    	getSqlMapClientTemplate().insert("insert_MakeGameInfo", map);
    }
    
    @SuppressWarnings({ "unchecked", "rawtypes" })
	public void updateMakeGameInfo(String gameId,int idcGamever,int localVersion,Date updateTime,String gameSize){
		Map map= new HashMap();
    	map.put("gameId", gameId);
    	map.put("idcGamever", idcGamever);
    	map.put("localVersion", localVersion);
    	map.put("releasetTime",updateTime);
    	map.put("gameSize",gameSize);
    	
    	getSqlMapClientTemplate().update("update_MakeGameInfo_byGameId", map);
    }
   
    public void insertIdcGroupGameInfo(String groupId,String gameId){
    	Map<String,String> map= new HashMap<String,String>();
    	map.put("groupId", groupId);
    	map.put("gameId", gameId);
    	getSqlMapClientTemplate().insert("insert_IdcGroupGameInfo", map);
    }
    /**
     * 
     * @param updatesrvId
     * @param gameId
     * @param idcGamever
     * @param gamePath
     * @param state 默认为：10
     * @param localVersion 默认为：10
     * @param totalSize
     * @param updateTime
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
	public void insertUsGameInfo(String updatesrvId,String gameId,String idcGamever,String gamePath,int state,int localVersion,String totalSize,Date updateTime){
    	Map map= new HashMap();
    	map.put("updateSrvId", updatesrvId);
    	map.put("gameId", gameId);
    	map.put("idcGamever", idcGamever);
    	map.put("gamePath", gamePath);
    	map.put("state",state);
    	map.put("localVersion",localVersion);
    	map.put("totalSize", totalSize);
    	map.put("updateTime", updateTime);
    	
       	getSqlMapClientTemplate().insert("insert_UsGameInfo", map);
    }
    /**
     * 
     * @param updatesrvId
     * @param gameId
     * @param state 默认为：10
     * @param localVersion 默认为：10
     * @param updateTime
     */
    @SuppressWarnings({"rawtypes", "unchecked" })
   	public void updateUsGameInfoForVersion(String updatesrvId,String gameId,int state,int localVersion,String totalSize,Date updateTime){
   		Map map= new HashMap();
       	map.put("updateSrvId", updatesrvId);
       	map.put("gameId", gameId);
       	map.put("state",state);
       	map.put("localVersion", localVersion);
       	map.put("totalSize", totalSize);
       	map.put("updateTime", updateTime);
       	getSqlMapClientTemplate().update("update_UsGameInfo", map);
      }
   
    

}